from common.base import Base, By, open_browser, sleep
import random

sj_account = 'ceshi2401'+str(random.randint(000000,999999))

class SellerRegPage(Base):
    seller_name_loc = (By.NAME, 'seller_name')  # 用户名输入框
    password_loc = (By.NAME, 'password')  # 密码输入框
    repassword_loc = (By.NAME, 'repassword')  # 重复密码输入框
    true_name_loc = (By.NAME, 'true_name')  # 公司真实全称
    phone_loc = (By.NAME, 'phone')  # 固定电话输入框
    mobile_loc = (By.NAME, 'mobile')  # 移动电话输入框
    email_loc = (By.NAME, 'email')  # 电子邮箱输入框
    submit_loc = (By.CLASS_NAME, 'submit')  # 注册按钮

    def input_seller_name(self,seller_name):
        self.send_keys(SellerRegPage.seller_name_loc,seller_name)

    def input_password(self,password):
        self.send_keys(SellerRegPage.password_loc,password)

    def input_repassword(self,repassword):
        self.send_keys(SellerRegPage.repassword_loc,repassword)

    def input_true_name(self,true_name):
        self.send_keys(SellerRegPage.true_name_loc,true_name)

    def input_phone(self,phone):
        self.send_keys(SellerRegPage.phone_loc,phone)

    def input_mobile(self,mobile):
        self.send_keys(SellerRegPage.mobile_loc,mobile)

    def input_email(self,email):
        self.send_keys(SellerRegPage.email_loc,email)

    def click_submit(self):
        self.click(SellerRegPage.submit_loc)

if __name__ == '__main__':
    reg = SellerRegPage(open_browser())
    reg.get_url('http://localhost/shop/index.php?controller=simple&action=reg')
    reg.input_username(sj_account)
    sleep(2)
    reg.input_password(sj_account)
    sleep(2)
    reg.input_repassword(sj_account)
    sleep(2)
    reg.input_captcha('55555')
    reg.click_reg()
    sleep(2)
    reg.close_browser()